package net.dodoman.thread;

public class TwoThreadTest {
	public static void main(String[] args) {
		Thread1 t1 = new Thread1();
		Thread2 t2 = new Thread2();
	}
}

class Thread1 extends Thread {
	public static int m = 0;

	public Thread1() {
		setDaemon(true);
		start();
	}

	@Override
	public void run() {
		while (true) {
			System.out.println("m=" + m);
			try{
			Thread.sleep(100);
			}catch (Exception e) {
			}
		}
	}

}

class Thread2 extends Thread {
	public Thread2() {
		start();
	}

	@Override
	public void run() {
		for (int i = 0; i < 10; i++) {
			System.out.println("i=" + i);
			Thread1.m = i;
			try {
				sleep(100);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
